package ru.spb.osll.myfit.wikiverifier;

import ru.spb.osll.myfit.wikiverifier.iterator.FileSystemIterator;
import ru.spb.osll.myfit.wikiverifier.iterator.WikiVerifierFSIteratorListener;
import ru.spb.osll.myfit.wikiverifier.resulthandler.AggregatedVerificationResultHandler;
import ru.spb.osll.myfit.wikiverifier.resulthandler.ConsoleVerificationResultHandler;
import ru.spb.osll.myfit.wikiverifier.resulthandler.PageVerificationResultHandler;


public class WikiVerifierMain {
    private String m_jarPath = "";
    private String m_verificationPath = "";
	
	public static void main(String[] args) {
		WikiVerifierMain wikiVerifierMain = new WikiVerifierMain();
		wikiVerifierMain.run(args);
	}
	
	public void run(String[] args) {
		if(args.length != 2) {
			usage();
		} else {
			m_jarPath = args[0];
			m_verificationPath = args[1];
			WikiVerifierFSIteratorListener listener = new WikiVerifierFSIteratorListener(m_jarPath, m_verificationPath);
			ConsoleVerificationResultHandler resultHandler = new ConsoleVerificationResultHandler();
			listener.addResultHandler((PageVerificationResultHandler)resultHandler);
			listener.addResultHandler((AggregatedVerificationResultHandler)resultHandler);
			FileSystemIterator iterator = new FileSystemIterator(m_verificationPath, listener);
			iterator.iterate();
		}
	}
	
	private void usage() {
		System.out.println("Usage: java -jar wikiVerifier.jar jarPath fitnesseRoot");
	}

}
